/*
 * @Date: 2023-01-22 02:17:37
 * @LastEditors: 恶名扬 2080156129@qq.com
 * @LastEditTime: 2023-01-22 07:33:16
 * @FilePath: \campus-repair-platform\server\schema\manage\repairer_type.js
 */
/**
 * list_schema  获取报修区域列表
 * query_schema   根据name模糊查询报修区域
 * add_schema   添加报修区域
 * update_schema  修改报修区域信息
 */

const joi = require("joi")
const { id, page, pagesize } = require("../common")

const name = joi
  .string()
  .min(1)
  .max(8)
  .error(new Error("报修区域名称格式有误"))
const description = joi
  .string()
  .min(1)
  .max(50)
  .error(new Error("报修区域描述格式有误"))

exports.list_schema = {
  query: {
    page,
    pagesize: joi
      .number()
      .min(1)
      .max(50)
      .error(new Error("数据条数格式有误"))
  },
}

exports.query_schema = {
  query: {
    page,
    pagesize,
    name: name,
  },
}

exports.add_schema = {
  body: {
    name: name.required(),
    description: description,
  },
}

exports.update_schema = {
  body: {
    id: id.required(),
    name,
    description,
  },
}
